package edu.whu.demo.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.whu.demo.domain.Commdity_SuppliersDTO;
import edu.whu.demo.domain.Commodity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface Commdity_SuppliersDao extends BaseMapper<Commdity_SuppliersDTO> {


    @Select("SELECT DISTINCT c.* FROM commodity c LEFT JOIN comm_supp cs ON c.id = cs.comm_id LEFT JOIN supplier s ON cs.supp_id = s.id WHERE c.id = #{id}")
    @Results({
            @Result(id = true,property = "id", column = "id"),
            @Result(property = "supplierList", column = "id", javaType = List.class, many = @Many(select = "edu.whu.demo.dao.SupplierDao.selectByCommId"))
    })
    Commdity_SuppliersDTO selectCommodityWithSuppliers(int id);
}
